#!/usr/bin/env python3
# Copyright (c) 2021 Qtclass Open Source Team. All rights reserved.
# SPDX-License-Identifier: MulanPSL-2.0
#
# Authors               Contact
# canopen               canopensrc@163.com
#
"""
This is create_repo script
"""

import sys
import os
import argparse

base_path = os.path.abspath(os.path.dirname(__file__) + "/..")
if base_path not in sys.path:
    sys.path.append(base_path)

from apps import qtclass

def parse_command_line():
    params = argparse.ArgumentParser()
    params.add_argument("-n", "--name", type=str, required=True,
                        help="the name of repo")
    params.add_argument("-d", "--desc", type=str, required=True,
                        help="The description of repo")
    params.add_argument("-l", "--license", type=str, default="",
                        help="The license of repo")
    args = params.parse_args()
    return args


def do_main(args):
    if not args.name or not args.desc:
        print("args invalid, please use -h for help")
        sys.exit(1)

    my_qtc = qtclass.Qtclass()
    my_qtc.create_org_repo(args.name, args.desc, "qtclass", args.license)


def main():
    args = parse_command_line()
    do_main(args)


if __name__ == "__main__":
    main()
